package main

import (
	"crypto/tls"
	"fmt"
	"time"
)

func main() {

	conn, err := tls.Dial("tcp", "snippetbox.lavenliu.cn:443", nil)
	if err != nil {
		panic("服务器不支持 SSL, err:" + err.Error())
	}

	err = conn.VerifyHostname("snippetbox.lavenliu.cn")
	if err != nil {
		panic("证书与域名不匹配, err:" + err.Error())
	}

	expirey := conn.ConnectionState().PeerCertificates[0].NotAfter
	fmt.Printf("Issuer: %s\nExpiry: %v\n", conn.ConnectionState().PeerCertificates[0].Issuer, expirey.Format(time.RFC850))
}
